package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	public class Enterframe_move extends Sprite
	{
		
		private var btm:Bitmap;
		private var bmd:BitmapData ;
		private var frameRate:int = 30;
		private var s_width:int;
		private var s_height:int;
		private var b_width:int = 10;
		private var b_height:int = 10;
		private var temp_x:int =1;
		private var add_x:int =2;
		private var temp_y:int =1;
		private var add_y:int =2;
		private var input:String;
		public function Enterframe_move()
		{
			bmd = new BitmapData(b_width,b_height,false,0xffcc00);
			btm= new Bitmap(bmd);
			var sp:Sprite = new Sprite();
			sp.addChild(btm);
			addChild(sp);
			this.addEventListener(MouseEvent.CLICK,clickhandler);
			this.addEventListener(Event.ENTER_FRAME,enter_frame_handle);
			this.stage.frameRate = frameRate;
			s_width = this.stage.stageWidth;
			s_height = this.stage.stageHeight;
			this.graphics.clear();
//			this.graphics.beginFill(0xff00cc,1);
			this.graphics.lineStyle(1,0xfffccc);
			this.graphics.lineTo(s_width,0);
			this.graphics.lineTo(s_width,s_height);
			this.graphics.lineTo(0,s_height);
			this.graphics.lineTo(0,0);
		}
		public function clickhandler(e:Event)
		{
			
		}
		public function enter_frame_handle(e:Event)
		{
			if(btm.x>=(s_width-b_width)&&btm.x>0)
			{
			
			temp_x =-add_x;
			}
			if(btm.x<=0){
				
			temp_x =add_x;
			}
			btm.x+= temp_x;
			
			//btm.y++;
			if(btm.y>=(s_height-b_height)&&btm.y>0)
			{
			
			temp_y =-add_y;
			}
			if(btm.y<=0){
				
			temp_y =add_y;
			}
			btm.y+= temp_y;
			
		}
	}
}